package com.stockz.scanner.screen;

import java.util.List;

import com.stockz.core.model.Bar;
import com.stockz.core.util.ListUtil;
import com.stockz.core.util.BarUtil.BarValueType;
import com.stockz.scanner.screen.configuration.SimpleConsolidationScreenConfiguration;
import com.stockz.ui.swing.charting.util.MathUtil;

public class ConsolidationBreakoutScreen1 implements Screen<SimpleConsolidationScreenConfiguration> {

	private final SimpleConsolidationScreen screen
	= new SimpleConsolidationScreen();
	
	@Override
	public SimpleConsolidationScreenConfiguration getConfiguration() {
		return screen.getConfiguration();
	}

	@Override
	public int getMandatorySpan() {
		return screen.getMandatorySpan();
	}

	@Override
	public boolean isMatch(List<Bar> barList) {
		int offset = 6;
		int span = 40;
		List<Bar> subList = barList.subList(offset, barList.size());
		boolean match = screen.isMatch(subList);
		if(match){
			double max = MathUtil.max(ListUtil.convert(barList, BarValueType.CLOSE, offset, span));
			return (barList.get(0).getClose() > max);
		}
		return false;
	}

}
